import {RouterMount,createRouter} from 'uni-simple-router';
import store from "@/store/index.js"
const router = createRouter({
	platform: process.env.VUE_APP_PLATFORM,  
	routes: [...ROUTES]
});
//全局路由前置守卫
router.beforeEach((to, from, next) => {
	const token=store.getters["user/getToken"]
	const isMock=store.state.user.isMock
	if(to.meta.auth&&!token){
		console.log("to is",to)
		next({path:"/pages/login/login",query:{redirect:to.path,_query:{...to.query}}, NAVTYPE: 'push'})
	}
	else if(to.meta.forbidenMock&&isMock){
		uni.showToast({
			icon:"none",
			title:"模拟禁止使用"
		})
		next(false)
	}
	else{
		next();
	}
	
});
// 全局路由后置守卫
router.afterEach((to, from) => {
})

export {
	router,
	RouterMount
}